﻿using System;
using System.Collections.Generic;

using Rarous.TexyNet;
using Rarous.TexyNet.Configuration;
using Rarous.TexyNet.Modules;

using Xunit;

namespace Rarous.TexyNet.Test {

  /// <summary>
  /// This is a test class for LinkModuleTest and is intended
  /// to contain all LinkModuleTest Unit Tests
  /// </summary>
  public class LinkModuleTest {

    /// <summary>
    /// A test for RootTest
    /// </summary>
    [Fact]
    public void LinkModule_Root_PropertyBehavior() {
      LinkModule target = new LinkModule();
      string expected = "/pages/";
      target.Root = expected;

      Assert.Equal(expected, target.Root);
    }

    /// <summary>
    /// A test for ReferencesTest
    /// </summary>
    [Fact]
    public void LinkModule_References_CollectionBehavior() {
      LinkModule target = new LinkModule();

      Assert.NotNull(target.References);
      Assert.Equal(0, target.References.Count);
      target.References.Add(new Reference("texy", "http://www.texy.info/"));
      Assert.Equal(1, target.References.Count);
    }

    /// <summary>
    /// A test for PopupOnClickTest
    /// </summary>
    [Fact]
    public void LinkModule_PopupOnClick_PropertyBehavior() {
      LinkModule target = new LinkModule();
      string expected = "javascript:close()";
      target.PopupOnClick = expected;

      Assert.Equal(expected, target.PopupOnClick);
    }

    /// <summary>
    /// A test for ImageOnClickTest
    /// </summary>
    [Fact]
    public void LinkModule_ImageOnClick_PropertyBehavior() {
      LinkModule target = new LinkModule();
      string expected = "javascript:close()";
      target.ImageOnClick = expected;

      Assert.Equal(expected, target.ImageOnClick);
    }

    /// <summary>
    /// A test for ForceNoFollowTest
    /// </summary>
    [Fact]
    public void LinkModule_ForceNoFollow_PropertyBehavior() {
      LinkModule target = new LinkModule();
      bool expected = true;
      target.ForceNoFollow = expected;

      Assert.Equal(expected, target.ForceNoFollow);
    }

    /// <summary>
    /// A test for EmailOnClickTest
    /// </summary>
    [Fact]
    public void LinkModule_EmailOnClick_PropertyBehavior() {
      LinkModule target = new LinkModule();
      string expected = "javascript:close()";
      target.EmailOnClick = expected;

      Assert.Equal(expected, target.EmailOnClick);
    }

    /// <summary>
    /// A test for AllowedUrlTest
    /// </summary>
    [Fact]
    public void LinkModule_AllowedUrl_PropertyBehavior() {
      LinkModule target = new LinkModule();
      bool expected = true;
      target.AllowedUrl = expected;

      Assert.Equal(expected, target.AllowedUrl);
    }

    /// <summary>
    /// A test for AllowedReferencesTest
    /// </summary>
    [Fact]
    public void LinkModule_AllowedReferences_PropertyBehavior() {
      LinkModule target = new LinkModule();
      bool expected = true;
      target.AllowedReferences = expected;

      Assert.Equal(expected, target.AllowedReferences);
    }

    /// <summary>
    /// A test for AllowedQuickLinkTest
    /// </summary>
    [Fact]
    public void LinkModule_AllowedQuickLink_PropertyBehavior() {
      LinkModule target = new LinkModule();
      bool expected = true;
      target.AllowedQuickLink = expected;

      Assert.Equal(expected, target.AllowedQuickLink);
    }

    /// <summary>
    /// A test for AllowedLinkTest
    /// </summary>
    [Fact]
    public void LinkModule_AllowedLink_PropertyBehavior() {
      LinkModule target = new LinkModule();
      bool expected = true;
      target.AllowedLink = expected;

      Assert.Equal(expected, target.AllowedLink);
    }

    /// <summary>
    /// A test for AllowedEmailTest
    /// </summary>
    [Fact]
    public void LinkModule_AllowedEmail_PropertyBehavior() {
      LinkModule target = new LinkModule();
      bool expected = true;
      target.AllowedEmail = expected;

      Assert.Equal(expected, target.AllowedEmail);
    }

    /// <summary>
    /// A test for LinkModuleConstructorTest1
    /// </summary>
    [Fact]
    public void LinkModule_Constructor_Default() {
      LinkModule target = new LinkModule();

      Assert.True(target.AllowedEmail);
      Assert.True(target.AllowedLink);
      Assert.True(target.AllowedQuickLink);
      Assert.True(target.AllowedReferences);
      Assert.True(target.AllowedUrl);
      Assert.False(target.ForceNoFollow);
      Assert.Equal(String.Empty, target.EmailOnClick);
      Assert.Equal(String.Empty, target.ImageOnClick);
      Assert.Equal(String.Empty, target.PopupOnClick);
      Assert.Equal(String.Empty, target.Root);
      Assert.NotNull(target.References);
    }

    /// <summary>
    /// A test for LinkModuleConstructorTest
    /// </summary>
    [Fact]
    public void LinkModule_Constructor_NullConfigElement() {
      LinkModule target = new LinkModule(null);

      Assert.True(target.AllowedEmail);
      Assert.True(target.AllowedLink);
      Assert.True(target.AllowedQuickLink);
      Assert.True(target.AllowedReferences);
      Assert.True(target.AllowedUrl);
      Assert.False(target.ForceNoFollow);
      Assert.Equal(String.Empty, target.EmailOnClick);
      Assert.Equal(String.Empty, target.ImageOnClick);
      Assert.Equal(String.Empty, target.PopupOnClick);
      Assert.Equal(String.Empty, target.Root);
      Assert.NotNull(target.References);
    }
  }
}
